﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Security.Policy;
using System.Threading.Tasks;
using System.Xml.Linq;
using CoreShop.Library;
using CoreShop.Model;
using CoreShop.Model.UI;
using CoreShop.Repository;
using Newtonsoft.Json;
using SqlSugar;


namespace CoreShop.Services
{
    /// <summary>
    /// 接口实现
    /// </summary>
    public class syssettingServices : Repository<syssetting>, IsyssettingServices
    {
        #region 实现重写增删改查操作==========================================================

        /// <summary>
        /// 重写异步插入方法
        /// </summary>
        /// <param name="entity">实体数据</param>
        /// <returns></returns>
        public bool InsertAsync(syssetting entity)
        {
            return base.Change<syssetting>().Insert(entity);
        }
        public bool InsertOrUpdate(List<syssetting> entity)
        {
            return base.InsertOrUpdate(entity);
        }
        /// <summary>
        /// 重写异步更新方法方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateAsync(syssetting entity)
        {
            return base.Change<syssetting>().Update(a => new syssetting()
            {
                verifyPayPassword = entity.verifyPayPassword,
                bonusSetting = entity.bonusSetting,
                bonusRatio = entity.bonusRatio,
            }, a => a.corpId == entity.corpId);
        }

        /// <summary>
        /// 重写异步更新方法方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateAsync(List<syssetting> entity)
        {
            bool returnKey = true;
            foreach (var item in entity)
            {
                returnKey = base.Change<syssetting>().Update(a => new syssetting()
                {
                    verifyPayPassword = item.verifyPayPassword,
                    bonusSetting = item.bonusSetting,
                    bonusRatio = item.bonusRatio,
                }, a => a.corpId == item.corpId);
            }
            return returnKey;
        }
               
        #endregion

        #region 获取缓存的所有数据==========================================================

        /// <summary>
        /// 获取缓存的所有数据
        /// </summary>
        /// <returns></returns>
        public List<syssetting> GetCaChe()
        {
            return base.GetList();
        }

        #endregion
        
    }
}